package com.csdj.service.impl;

import com.csdj.entity.Cart;
import com.csdj.entity.Foodlist;
import com.csdj.mapper.CartMapper;
import com.csdj.service.ICartService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zq
 * @since 2024-12-11
 */
@Service
public class CartServiceImpl extends ServiceImpl<CartMapper, Cart> implements ICartService {
    @Autowired
    private CartMapper cartMapper;

    @Override
    public List<Cart> queryCart(Cart cart) {
        return cartMapper.selectCart(cart);
    }

    @Override
    public PageInfo<Cart> queryPagecart(int currentPage, int pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<Cart> carts = cartMapper.selectPageCart();
        PageInfo<Cart> pageInfo = new PageInfo<>(carts);
        return pageInfo;
    }

    @Override
    public int delete(int cartId) {
        return cartMapper.delete(cartId);
    }
}
